<template>
  <div class="app-container">
    <div class="filter-container default-box">
      <span>订单编号：</span>
      <el-input v-model="listQuery.title" placeholder="请输入订单编号" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">旅游产品：</span>
      <el-input v-model="listQuery.title" placeholder="请输入旅游产品：" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">用户：</span>
      <el-input v-model="listQuery.title" placeholder="请输入用户" style="width: 240px;" class="filter-item" />
      <span style="padding-left: 100px;">状态：</span>
      <el-select v-model="statusvalue" filterable placeholder="请选择">
        <el-option v-for="item in statusoptions" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
      <el-button class="filter-item" type="primary" icon="el-icon-search" style="margin-left:50px" round>
        查询
      </el-button>
      <el-button class="filter-item" icon="el-icon-refresh-right" round>
        重置
      </el-button>
    </div>
    <div class="default-box">
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="订单编号" width="250">
          <template>
            <span>J202303071526185050</span>
          </template>
        </el-table-column>
        <el-table-column label="旅游产品" width="300" show-overflow-tooltip>
          <template>
            <span>老君山一日游老君山一日游老君山一日游老君山一日游老君山一日游老君山一日游</span>
          </template>
        </el-table-column>
        <el-table-column label="用户" width="250">
          <template>
            <span>章鱼小丸子(<span :style="{color:$store.state.settings.theme}">15820882515</span>)</span>
          </template>
        </el-table-column>
        <el-table-column label="出游日期" width="250">
          <template>
            <span>2023-03-20</span>
          </template>
        </el-table-column>
        <el-table-column label="积分" width="200">
          <template>
            <span>1000.0000</span>
          </template>
        </el-table-column>
        <el-table-column label="手续费" width="200">
          <template>
            <span>1000.0000</span>
          </template>
        </el-table-column>
        <el-table-column label="总花费" width="200">
          <template>
            <span>1000.0000</span>
          </template>
        </el-table-column>
        <el-table-column label="联系人信息" width="250">
          <template>
            <span>胡歌: 15825323232</span>
          </template>
        </el-table-column>
        <el-table-column label="下单时间" width="200">
          <template>
            <span>2023-03-20 18:52:47</span>
          </template>
        </el-table-column>
        <el-table-column label="完成时间" width="200">
          <template>
            <span>2023-03-20 18:52:47</span>
          </template>
        </el-table-column>
        <el-table-column label="取消时间" width="200">
          <template>
            <span>2023-03-20 18:52:47</span>
          </template>
        </el-table-column>
        <el-table-column label="返回时间" width="200">
          <template>
            <span>2023-03-20 18:52:47</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" width="250">
          <template>
            <span class="warning-color">
              已支付
            </span>
            <span class="info-color">已取消</span>
            <span class="danger-color">[自动]</span>
          </template>
        </el-table-column>
        <el-table-column label="操作人" width="200">
          <template>
            <span>章鱼小丸子</span>
          </template>
        </el-table-column>
        <el-table-column label="操作记录" width="200">
          <template>
            <span>章鱼小丸子操作</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="250" class-name="small-padding fixed-width">
          <template>
            <el-button type="primary" round @click="handleDelete('finish','完成')">完成订单</el-button>
            <el-button type="warning" round @click="handleDelete('back','退回')">退回订单</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Adminrole',
  components: { Pagination },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      statusoptions: [{ // 状态选择项组
        value: '',
        label: '不限'
      }, {
        value: '待支付',
        label: '待支付'
      }, {
        value: '已支付',
        label: '已支付'
      }, {
        value: '已完成',
        label: '已完成'
      }, {
        value: '已取消',
        label: '已取消'
      }, {
        value: '已退回',
        label: '已退回'
      }],
      statusvalue: ''// 状态的类型
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    // 删除
    handleDelete(type, tip) {
      this.$confirm('确定要' + tip + '该旅游订单吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        center: true,
        customClass: 'text-center'
      }).then(() => {
        this.$notify({
          title: '成功',
          message: '删除成功',
          type: 'success',
          duration: 2000
        })
        // this.$message({
        //   type: 'success',
        //   message: '删除成功!'
        // })
      }).catch(() => {

      })
    }
  }
}
</script>
<style scoped>
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
  ::v-deep .filter-container .el-input--medium .el-input__inner{
    width: 240px;
  }
</style>
